using System;
using UnityEngine;
using UnityEngine.UIElements;

public class GameMenuPanel : MonoBehaviour
{
    private Button primaryButton;
    private Button intermdiateButton;
    private Button seniorButton;

    public ObjectEventSO primaryButtonEvent;
    public ObjectEventSO intermdiateButtonEvent;
    public ObjectEventSO seniorButtonEvent;
    
    public ObjectEventSO newGameEvent;
    public ObjectEventSO loadMapEvent;

    private void OnEnable()
    {
        primaryButton = GetComponent<UIDocument>().rootVisualElement.Q<VisualElement>().Q<Button>("Primary");
        intermdiateButton = GetComponent<UIDocument>().rootVisualElement.Q<VisualElement>().Q<Button>("Intermediate");
        seniorButton = GetComponent<UIDocument>().rootVisualElement.Q<VisualElement>().Q<Button>("Senior");

        primaryButton.clicked += OnPrimaryButtonClicked;
        intermdiateButton.clicked += OnIntermdiateButtonClicked;
        seniorButton.clicked += OnSeniorButtonClicked;
    }

    private void OnPrimaryButtonClicked()
    {
        primaryButtonEvent.RaisEvent(null, this);
        newGameEvent.RaisEvent(null, this);
        loadMapEvent.RaisEvent(null,this);
    }
    
    private void OnIntermdiateButtonClicked()
    {
        intermdiateButtonEvent.RaisEvent(null, this);
        newGameEvent.RaisEvent(null, this);
        loadMapEvent.RaisEvent(null,this);
    }
    
    private void OnSeniorButtonClicked()
    {
        seniorButtonEvent.RaisEvent(null, this);
        newGameEvent.RaisEvent(null, this);
        loadMapEvent.RaisEvent(null,this);
    }
}
